package com.feeyin.radar.commons;

public class Page_main
{
  private int currentPage = 0;
  private int totalPages = 0;
  private int pageRecorders = 0;
  private int totalRows = 0;
  private int pageStartRow = 0;
  private int pageEndRow = 0;
  private boolean hasNextPage = false;
  private boolean hasPreviousPage = false;

  public int getCurrentPage() {
    return this.currentPage;
  }
  public void setCurrentPage(int currentPage) {
    this.currentPage = currentPage;
  }
  public int getTotalPages() {
    return this.totalPages;
  }
  public void setTotalPages(int totalPages) {
    this.totalPages = totalPages;
  }
  public int getPageRecorders() {
    return this.pageRecorders;
  }
  public void setPageRecorders(int pageRecorders) {
    this.pageRecorders = pageRecorders;
  }
  public int getTotalRows() {
    return this.totalRows;
  }
  public void setTotalRows(int totalRows) {
    this.totalRows = totalRows;
  }
  public int getPageStartRow() {
    return this.pageStartRow;
  }
  public void setPageStartRow(int pageStartRow) {
    this.pageStartRow = pageStartRow;
  }
  public int getPageEndRow() {
    return this.pageEndRow;
  }
  public void setPageEndRow(int pageEndRow) {
    this.pageEndRow = pageEndRow;
  }
  public boolean isHasNextPage() {
    return this.hasNextPage;
  }
  public void setHasNextPage(boolean hasNextPage) {
    this.hasNextPage = hasNextPage;
  }
  public boolean isHasPreviousPage() {
    return this.hasPreviousPage;
  }
  public void setHasPreviousPage(boolean hasPreviousPage) {
    this.hasPreviousPage = hasPreviousPage;
  }

  public Page_main(int pageRecorders, int currentPage, int flag, int totalRows) {
    this.currentPage = currentPage;

    if (totalRows % pageRecorders == 0)
      this.totalPages = (totalRows / pageRecorders);
    else {
      this.totalPages = (totalRows / pageRecorders + 1);
    }

    this.totalRows = totalRows;

    if ((flag == 1) && (this.currentPage == 0)) {
      this.pageStartRow = 0;
      this.pageEndRow = pageRecorders;
      this.currentPage = 1;
    } else if (flag == 2) {
      if (this.currentPage > 0) {
        this.currentPage -= 1;
        this.pageStartRow = (this.currentPage * pageRecorders);
        this.pageEndRow = pageRecorders;
      }
    } else if (flag == 3) {
      if (this.currentPage < this.totalPages) {
        this.currentPage += 1;
        this.pageStartRow = (this.currentPage * pageRecorders);
        this.pageEndRow = pageRecorders;
      }
    } else if ((flag == 4) && (this.currentPage == this.totalPages)) {
      this.currentPage -= 1;
      this.pageStartRow = (this.currentPage * pageRecorders);
      this.pageEndRow = pageRecorders;
    }
  }
}